<?php
namespace app\common\model;

use think\Model;

class ItemCate extends Model {
	/**
	 * 获取分类列表
	 *
	 * @param  array  $map [description]
	 * @return [type]      [description]
	 */
	public function getList($map = []) {
		return $this->where($map)->order('level')->select();
	}

	/**
	 * 添加/修改分类
	 *
	 * @param [type] $data [description]
	 */
	public function editInfo($data) {
		$file = request()->file('cate_pic');
		if ($file) {
			return $file;
			$path = '/upload/catepic/';
			$info = $file->rule('uniqid')->move('.' . $path);
			if ($info) {
				$data['cate_pic'] = $path . $info->getSaveName();
			}
		} else {
			unset($data['cate_pic']);
		}

		return $this->update($data);
	}

}